// import request from '@/utils/request'
import http from '@/api/request'
import axios from 'axios'
import { getToken } from '@/utils/auth'
import { getConfig } from '@/config/config'
import CryptoJS from "crypto-js"
const api = {
	/**
	 * 获取字典，数据结构为res.data中key:[]
	 * @param {Object} query
	 */
	getDictList(query) {
		return http({
			url: '/tug-api/internal/public/getDictList',
			method: 'get',
			params: query,
		})
	},
	/**
	 * 获取字典，数据结构为res.data
	 * @param {String} type 字典类型
	 */
	getDictListByType(type) {
		return http({
			url: `/tug-api/internal/public/getDictListByType/${type}`,
			method: 'get',
		})
	},
	/**
	 * 获取远程下拉框数据
	 * @param {*} query { type:String 下拉框类型,valueContent:String 根据value查,labelContent:String 根据label查, number:Number 默认显示条数 }
	 */
	getRemoteSelect(query) {
		return http({
			url: '/tug-api/internal/public/getRemoteSelect',
			method: 'post',
			data: query,
		})
	},
	/**
	 * 根据type获取本地下拉框数据
	 * @param {*} params 下拉框类型type,其他参数
	 */
	getLocalSelect(params) {
		return http({
			url: `/tug-api/internal/public/getLocalSelect`,
			method: 'get',
			params,
		})
	},
	/**
	 * 根据types获取本地下拉框数据
	 * @param {*} params { types:String 下拉框类型 }
	 */
	getLocalSelects(params) {
		return http({
			url: '/tug-api/internal/public/getLocalSelects',
			method: 'get',
			params,
		})
	},
	/**
	 * 上传文件
	 * @param {*} query
	 */
	getFileInfo(query) {
		return http({
			url: '/tug-api/internal/file/upload',
			method: 'post',
			data: query,
		})
	},
	/**
	 * 下载文件
	 * @param {String} id 文件id
	 */
	down(id, responseType = 'blob') {
		return axios({
			url: `/tug-api/internal/file/download/${id}`,
			// url: `/tug-api/internal/file/download?id=${id}`,
			// url: `/tug-api/internal/file/preview?id=${id}`,
			method: 'get',
			responseType,
			headers: {
				  'Authorization' : `Basic ${CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(`${getConfig('clientId')}:${getConfig('clientSecret')}`))}`,
				 'qdport-Auth': 'bearer ' + getToken(),
					 'token':getToken()
			  },
		})
	},
	/**
	 * 通过id获取文件信息
	 * @param {Object} params {businessId:'',businessType:''}
	 */
	getBusFiles(params) {
		return http({
			url: '/tug-api/internal/file/getBusFiles',
			method: 'get',
			params,
		})
	},
	/**
	 * 通用组织架构树
	 * @param {*} params 查询条件
	 * @returns
	 */
	getDeptList(params) {
		return http({
			url: '/tug-api/internal/public/getDeptList',
			method: 'get',
			params,
		})
	},
	/**
	 * 获取当前登录人信息
	 * @param {Object} params 检索条件的obj
	 */
	getLoginMess() {
		return http({
			url: '/tug-api/v1/internal/tPrdAttendance/getCompanyClass',
			method: 'get',
		})
	},
  /**
   * 获取当前登录人信息
   * @param {Object} params 检索条件的obj
   */
  getLoginDeptMess() {
    return http({
      url: '/tug-api/v1/internal/tPrdAttendance/getCompanyDeptClass',
      method: 'get',
    })
  },
}
export default api
